<?php
namespace app\index\validate;

use think\Validate;

class AddValidate extends Validate
{
    // 验证规则
    protected $rule = [
        'username' => ['require', 'min' => 3, 'max' => 12],
        'email' => ['require','regex' => '^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$'],
        'qq' => ['require', 'regex' => '/^[1-9][0-9]{4,11}$/'],
        'password' => ['require', 'regex' => '/^[A-Za-z]+[0-9]+[A-Za-z0-9]*|[0-9]+[A-Za-z]+[A-Za-z0-9]*$/'],
        'tel' => ['require', 'regex' => '/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$/'],


    ];
    // 提示信息
    protected $message = [
        'username.require' => '用户名必须填写^-^!',
        'username.min' => '用户名过短^-^',
        'username.max' => '用户名过长^-^',
        'email.require'=> '用户邮箱必须填写哦~',
        'email.regex' => '请填写正确的邮箱格式',
        'qq.require' => '用户qq必须填写^-^!',
        'qq.regex' => '请填写正确的QQ!',
        'tel.require' => '用户电话必须填写^-^!',
        'tel.regex' => '请填写地球上支持的电话格式!',
        'password.require' => '用户密码必须填写^-^!',
        'password.regex' => '用户密码格式不正确,请重新填写^-^!',
    ];
}